package javablackbelt.beans;

import java.util.Date;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

public class SimpleBankService implements BankService, InitializingBean, DisposableBean {

	protected final static Logger logger = Logger.getLogger(SimpleBankService.class);

	private double interestRate;
	
	private Date reportDate;
	
	private RateExchangeGateway rateExchangeGateway;

	public double computeBalanceWithInterests(double balance) {
		return balance * (1 + getInterestRate()/100.0);
	}
	
	public double getInterestRate() {
		return interestRate;
	}

	public void setInterestRate(double interestRate) {
		this.interestRate = interestRate;
	}

	
	public RateExchangeGateway getRateExchangeGateway() {
		return rateExchangeGateway;
	}

	public void setRateExchangeGateway(RateExchangeGateway rateExchangeGateway) {
		this.rateExchangeGateway = rateExchangeGateway;
	}
	
	public Date getReportDate() {
		return reportDate;
	}

	public void setReportDate(Date reportDate) {
		this.reportDate = reportDate;
	}

	public void afterPropertiesSet() throws Exception {
		logger.info("Executing afterPropertiesSet()");
	}

	public void destroy() throws Exception {
		logger.info("Executing destroy()");
	}

}
